#include "BleKeyboard.h"

#include <LittleFS.h>
#include <ArduinoHA.h>
#include "FileHelper.h"
#include "BleBasic.h"

class BleDangbei : public BleKeyboard, public BleBasic
{
private:
    /* data */
    static const uint16_t SyncInterval = 20000;
    uint8_t wakeTimes = 0;
    FileHelper fileHelper;
    HASwitch *powerSwitch;
    uint32_t _lastSyncAt;
    virtual void onAuthenticationComplete(ble_gap_conn_desc* desc) override;
    virtual void onConnect(BLEServer *pServer) override;
    virtual void onDisconnect(BLEServer *pServer) override;

public:
    BleDangbei(HADevice &device, std::string deviceName = "ESP32 Keyboard", std::string deviceManufacturer = "Espressif Systems", uint8_t batteryLevel = 80);
    ~BleDangbei();
    void wakeup();
    void shutdown();
    void initDevice();
    void updateSyncAt();
    void sync();
};
